const mongoose = require('mongoose')

const { Schema } = mongoose
// const BaseModel = require('./baseModel')

const PageSchema = new Schema({
  title: { type: String },
  path: { type: String },
  imgUrl: { type: String },
  content: { type: String },
  author: { type: String },
  isValid: { type: Number, default: 0 }, // 0 无效 1有效
  read_count: { type: Number, default: 0 },
  create_at: { type: Date, default: Date.now },
  update_at: { type: Date, default: Date.now },
})
PageSchema.index({ path: 1 }, { unique: true })
PageSchema.pre('save', function (next) {
  this.update_at = new Date()
  next()
})
mongoose.model('Page', PageSchema)
